package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import java.util.Set;

import org.testng.annotations.Test;
public class GroupModificationTests extends TestBase {
	
	protected void verifyGroupModified(Set<GroupObject> oldList, GroupObject validGroup, Set<GroupObject> newList) {
		assertThat(newList.size(), equalTo(oldList.size()));
	}

	@Test
	public void testFirstGroupCanBeModified() throws Exception {
		GroupObject validGroup = new GroupObject()
				 .setName("346456").setHeader("345353").setFooter("3453253");
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		app.getGroupHelper().modifyGroup(0, validGroup);
		Set<GroupObject> newList = app.getGroupHelper().getGroups();
		verifyGroupModified(oldList, validGroup, newList);
	}

	@Test
	public void testRandomGroupCanBeModified() throws Exception {
		GroupObject validGroup = new GroupObject()
				 .setName("test").setHeader("test53").setFooter("test3253");
		Set<GroupObject> oldList = app.getGroupHelper().getGroups();
		app.getGroupHelper().modifyGroup(app.getGroupHelper().getRandomGroupPosition(), validGroup);
		Set<GroupObject> newList = app.getGroupHelper().getGroups();
		verifyGroupModified(oldList, validGroup, newList);
	}
	
	
}
